package ${entityPackage}

<#list importList as item>
import ${item}
</#list>

/**
 * ${tableComment}(table: ${tableName})
 * @author ${author}
 * @since ${date}
 */
@TableName("${tableName}")
<#if enableSwagger3>
@Schema(name = "${tableComment}实体信息")
</#if>
open class ${entityName} {

<#if primaryColumn?size==1>
    <#list primaryColumn as column>
        <#if enableColumnComment>
    /** ${column.comment} */
        </#if>
        <#if enableSwagger3>
    @Schema(title = "${column.comment}" , description = "${column.comment}")
        </#if>
    @TableId("${column.name}")
    var ${column.javaFiled}: ${column.javaType}? = null

    </#list>
</#if>
<#if (primaryColumn?size > 1)>
    <#list primaryColumn as column>
        <#if enableColumnComment>
    /** ${column.comment} */
        </#if>
        <#if enableSwagger3>
    @Schema(title = "${column.comment}" , description = "${column.comment}")
        </#if>
    @TableField("${column.name}")
    var ${column.javaFiled}: ${column.javaType}? = null

    </#list>
</#if>
<#if (normalColumn?size > 0)>
<#list normalColumn as column>
    <#if enableColumnComment>
    /** ${column.comment} */
    </#if>
    <#if enableSwagger3>
    @Schema(title = "${column.comment}", description = "${column.comment}")
    </#if>
    <#if enableMyBatisPlus>
    @TableField("${column.name}")
    </#if>
    var ${column.javaFiled}: ${column.javaType}? = null

</#list>
</#if>
<#if generateConvert>
    companion object{
        /**
        * 继承类转换
        * @author ${author}
        * @since ${date}
        * @param source: 源对象
        * @param target: 目标对象
        */
        @JvmStatic
        fun ${"<S"?js_string} : ${entityName},T : ${entityName}<#noparse>></#noparse> convert(source: S?,target: T) : T?{
            if (source == null) return null
            target.apply {
            <#list columns as column>
                this.${column.javaFiled} = source.${column.javaFiled}
            </#list>
            }
            return target;
        }
    }
</#if>
}
